﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using SilverlightContrib.Controls;
using XamlaApp.ViewModels;
using XamlaApp.Interfaces;

namespace XamlaApp.Views.ElementPropertyViews
{
    public partial class ShapeProperties : UserControl
    {
        public ShapeProperties()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //toggle the pop up visibility
            var p = (Popup)((Button)sender).Tag;
            p.IsOpen = p.IsOpen ? false : true;
        }

        private readonly MainUIViewModel _muvm = Container.AppContainer.Resolve<MainUIViewModel>();
        private void ColorPicker_SelectedFillColorChanging(object sender, SelectedColorEventArgs e)
        {
            ((ShapeViewModel)((IXamlaElement)_muvm.CurrentElement).ViewModel).FillBrush = new SolidColorBrush(e.SelectedColor);
        }

        private void ColorPicker_SelectedStrokeChanging(object sender, SelectedColorEventArgs e)
        {
            ((ShapeViewModel)((IXamlaElement)_muvm.CurrentElement).ViewModel).StrokeBrush = new SolidColorBrush(e.SelectedColor);
        }
    }
}
